
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class GradientPen

    Private Sub GradientPen_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim cx As Integer = Me.Width
        Dim cy As Integer = Me.Height
        Dim lgbrush As new LinearGradientBrush(new Rectangle(0, 0, cx, cy), Color.White, Color.Black,LinearGradientMode.BackwardDiagonal)

        Dim pen As New Pen(lgbrush, Math.Min(cx, cy) / 25)

        pen.Alignment = PenAlignment.Inset

        e.Graphics.DrawRectangle(pen, 0, 0, cx, cy)
        e.Graphics.DrawLine(pen, 0, 0, cx, cy)
        e.Graphics.DrawLine(pen, 0, cy, cx, 0)

    End Sub
End Class
